home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / intrfc61.arc / INTRFC.PAS < prev    next >
Pascal/Delphi Source File  |  1991-03-28  |  4KB  |  121 lines

  1. program intrfc;
  2. {  Prints out the information contained in a TPU file  }
  3.  
  4. uses
  5.   test1,nametype,util,globals,loader,head,blocks,namelist,srcfiles,code,
  6.         reloc,dump,params;
  7.  
  8. var
  9.   i,j,t:word;
  10.   result : word;
  11.   this_unit : obj_ptr;
  12.   tpu_size : longint;
  13.   main_list : list_ptr;
  14. begin
  15.   writeln('INTRFC version 1.31.  Written by D.J. Murdoch.');
  16.  
  17.   parse_params;
  18.  
  19.   writeln('Dump of file ',unitname,'.TPU');
  20.  
  21.   read_file('turbo.tpl',pointer(tpl_buffer),0,65535);
  22.   if tpl_buffer = nil then
  23.     read_file(uses_path+'turbo.tpl',pointer(tpl_buffer),0,65535);
  24.   if tpl_buffer <> nil then
  25.   begin
  26.     got_tpl := true;
  27.     tpl_size := last_file_size;
  28.   end
  29.   else
  30.   begin
  31.     got_tpl := false;
  32.     writeln('Warning:  TURBO.TPL not found.');
  33.   end;
  34.  
  35.   num_known := 0;
  36.   fillchar(unit_list,sizeof(unit_list),0);
  37.   add_unit(unitname);
  38.   if not unit_list[1]^.has_symbols then
  39.     syntax_exit('');
  40.  
  41.   buffer := unit_list[1]^.buffer;
  42.   header := normalize(buffer);
  43.  
  44.   {Make this unit refer to itself}
  45.   this_unit := add_offset(buffer,header^.ofs_this_unit);
  46.   unit_ptr(add_offset(this_unit,length(this_unit^.name)+4))^.target := 1;
  47.  
  48.   add_referenced_units;
  49.  
  50.   with header^ do
  51.     begin
  52.       code_ofs  := roundup(sym_size,16);
  53.       const_ofs := code_ofs + roundup(code_size,16);
  54.       reloc_ofs := const_ofs + roundup(const_size,16);
  55.       vmt_ofs   := reloc_ofs + roundup(reloc_size,16);
  56.       tpu_size := longint(roundup(sym_size,16))
  57.                  +longint(roundup(code_size,16))
  58.                  +longint(roundup(const_size,16))
  59.                  +longint(roundup(reloc_size,16))
  60.                  +longint(roundup(vmt_size,16));
  61.     end;
  62.  
  63.  
  64.   hash_table := add_offset(buffer,header^.ofs_hashtable);
  65.   if do_implementation in active_options then
  66.     hash_table := add_offset(buffer,header^.ofs_full_hash);
  67.  
  68.   {Build main object list}
  69.  
  70.   build_list(main_list,buffer,hash_table);
  71.   unit_list[1]^.obj_list := main_list;
  72.  
  73.   { Now print it }
  74.   in_function := false;
  75.   indentation := 0;
  76.   if do_header in active_options then
  77.     print_header;
  78.   if [do_name_list,do_implementation]*active_options <> [] then
  79.     print_name_list(main_list);
  80.   if do_src_files in active_options then
  81.     print_src_files;
  82.   if do_src_lines in active_options then
  83.     print_src_lines;
  84.   if do_entry_pts in active_options then
  85.     print_entries;
  86.   if do_code_blocks in active_options then
  87.     print_code_blocks;
  88.   if do_const_blocks in active_options then
  89.     print_const_blocks;
  90.   if do_var_blocks in active_options then
  91.     print_var_blocks;
  92.   if do_mystery in active_options then
  93.     print_mystery;
  94.   if do_unit_blocks in active_options then
  95.     print_unit_blocks;
  96.   if do_code in active_options then
  97.   begin
  98.     read_file(unit_list[1]^.path,pointer(code_buf),code_ofs,header^.code_size);
  99.     print_dump(code_seg);
  100.     freemem(code_buf,header^.code_size);
  101.   end;
  102.   if do_const in active_options then
  103.   begin
  104.     read_file(unit_list[1]^.path,pointer(code_buf),const_ofs,header^.const_size);
  105.     print_dump(const_seg);
  106.     freemem(code_buf,header^.const_size);
  107.   end;
  108.   if do_reloc in active_options then
  109.   begin
  110.     read_file(unit_list[1]^.path,pointer(reloc_buf),reloc_ofs,header^.reloc_size);
  111.     print_reloc(code_seg);
  112.     freemem(reloc_buf,header^.reloc_size);
  113.   end;
  114.   if do_vmt in active_options then
  115.   begin
  116.     read_file(unit_list[1]^.path,pointer(reloc_buf),vmt_ofs,header^.vmt_size);
  117.     print_reloc(const_seg);
  118.     freemem(reloc_buf,header^.vmt_size);
  119.   end;
  120. end.
  121.